/*
 * @Author: zhang gen yuan
 * @Date: 2021-08-16 09:33:53
 * @Descripttion: 
 */

import { createStore, createLogger } from 'vuex'
import getters from './getters'
import createPersistedState from 'vuex-persistedstate'
let modules = {}
const modulesFiles = import.meta.globEager('./modules/*.js')
for (const path in modulesFiles) {
  const moduleName = path.replace(/(.*\/)*([^.]+).*/gi, '$2')
  modules = {
    ...modules,
    [moduleName]:modulesFiles[path].default
  }
}

const isDev = import.meta.env.MODE !== 'production'
const store = createStore({
  plugins:[createPersistedState()],
  modules,
  getters,
  strict: isDev,
})

export function setupStore(app) {
  app.use(store)
  console.log(store, 'vuex')
}

export default store;
